< previous page page_343 next page >

Page 343
Resume Next in the Error Label
Another method of using the Resume Next statement is to use it in the error label itself. Of course, this is not often done, but it is presented here just for completeness:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdResumeNext2_Click()
   ' Delete a file, if it exists.
   On Error GoTo Error_EH

   Stop

   Kill txtFileKill

   Err.Clear

NormalExit:
   Exit Sub

Error_EH:
   Resume Next
End Sub
In this code, a normal error trap is set using a label name. Inside of the label, Resume Next is called, and it jumps to the line after the line that has the error.
Resume <LabelName>
Sometimes youll want to just ignore errors or go to a different location when an error occurs. You should be very careful when using this technique, because you could make your code kind of hard to follow. Figure 17.5 shows the sample that will illustrate this technique.
Examples Filename: FileLen.frm
8160-0343a.gif
Figure 17.5
The Resume to Label and Resume examples.

 
< previous page page_343 next page >

If you like this book, buy it!